package com.example.mybatis.controller;


import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.example.mybatis.bean.TestScore;
import com.example.mybatis.service.TestScoreService;
import com.example.mybatis.utils.ResultUtil;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Date;


@RestController
@RequestMapping("testScore")
public class TestScoreController {

    @Resource
    TestScoreService testScoreService;

    @RequestMapping("selectList")
    public ResultUtil selectList(Double testScore,Integer current,Integer size) {
        return testScoreService.selectList(testScore, current, size);

    }

    @RequestMapping("save")
    public ResultUtil save(TestScore testScore){
        //数据校验
       /* testScoreService.save(testScore);
        return ResultUtil.ok();*/
        return testScoreService.insert(testScore);
    }

    @RequestMapping("updateById")
    public ResultUtil updateById(TestScore testScore){
        //数据校验

      /*  UpdateWrapper<TestScore> updateWrapper=new UpdateWrapper<>();
        updateWrapper.eq("id",testScore.getId())
                .set("test_score",testScore.getTestScore())
                .set("renewal_time",new Date());
*/
   /*     LambdaUpdateWrapper<TestScore> lambdaUpdateWrapper=new LambdaUpdateWrapper<>();
        lambdaUpdateWrapper.eq(TestScore::getId,testScore.getId())
                .set(TestScore::getTestScore,testScore.getTestScore());*/


        //testScoreService.updateById(testScore);
       // testScoreService.update(updateWrapper);
      // testScoreService.update(lambdaUpdateWrapper);
        return testScoreService.update(testScore);
    }

    @RequestMapping("removeById")
    public ResultUtil removeById(String id){
        //数据校验

        testScoreService.removeById(id);
        return ResultUtil.ok();
    }

}
